// 这个模块主要是获取spu模块的数据
import request from '@/utils/request'

// 获取spu列表展示数据  /admin/product/{page}/{limit}   get    page limit category3Id
export const reqSpuList = (page, limit, category3Id) => {
  return request({ url: `/admin/product/${page}/${limit}`, params: { category3Id }, method: 'get' })
}

// 获取某一个SPU基本信息  /admin/product/getSpuById/{spuId}  get
export const reqSpuInfo = (spuId) => {
  return request({ url: `/admin/product/getSpuById/${spuId}`, method: 'get' })
}
// 获取品牌列表数据  /admin/product/baseTrademark/getTrademarkList    get
export const reqGetTrademarkList = () => {
  return request({ url: '/admin/product/baseTrademark/getTrademarkList', method: 'get' })
}
// 获取SPU图片信息  /admin/product/spuImageList/{spuId}  get
export const reqSpuImageList = (spuId) => {
  return request({ url: `/admin/product/spuImageList/${spuId}`, method: 'get' })
}

// 获取平台中全部的销售属性  /admin/product/baseSaleAttrList  get
export const reqBaseSaleAttrList = () => {
  return request({ url: '/admin/product/baseSaleAttrList', method: 'get' })
}

// 修改SPU | 添加SPU信息：对于修改或者添加，携带给服务器参数大致一样，唯一的区别就是携带的参数是否带id
// 接口  /admin/product/updateSpuInfo   post
export const reqAddOrUpdateSpuInfo = (spu) => {
  // 携带参数带有id ----修改spu
  if (spu.id) {
    return request({ url: '/admin/product/updateSpuInfo', method: 'post', data: spu })
  } else {
  // 携带参数不带id ----修改spu
    return request({ url: '/admin/product/saveSpuInfo', method: 'post', data: spu })
  }
}

// 删除某一个 SPU    /admin/product/deleteSpu/{spuId}   delete
export const reqDeleteSpu = (spuId) => {
  return request({ url: `/admin/product/deleteSpu/${spuId}`, method: 'delete' })
}
